local jiu_Effect = fk.CreateSkill {

  name = "jiu_effect",

  tags = {},

}

THB_Utility = require("packages/thbattle/THB_Utility")

jiu_Effect:addEffect(fk.PreCardUse, {
  global = true,
  priority = 0, -- game rule
  can_trigger = function(_, event, target, player, data)
    if target ~= player or player:getMark("@@hezui") == 0 then
      return false
    end
    return data.card.trueName == "slash"
  end,
  on_trigger = function(_, event, _, player, data)
    local room = player.room
    data.additionalDamage = (data.additionalDamage or 0) + 1
    THB_Utility.removeStatusMark(player, "@@hezui")
  end,
})
jiu_Effect:addEffect(fk.EventPhaseStart, {
  global = true,
  priority = 0, -- game rule
  can_trigger = function(_, event, target, player, data)
    if target ~= player or player:getMark("@@hezui") == 0 then
      return false
    end
    return player.phase == Player.Start
  end,
  on_trigger = function(_, event, _, player, data)
    local room = player.room
    THB_Utility.removeStatusMark(player, "@@hezui")
  end,
})
jiu_Effect:addEffect(fk.DamageInflicted, {
  global = true,
  priority = 0, -- game rule
  can_trigger = function(_, event, target, player, data)
    if target ~= player or player:getMark("@@hezui") == 0 then
      return false
    end
    return data.damage >= player.hp + player.shield
  end,
  on_trigger = function(_, event, _, player, data)
    local room = player.room
    data.damage = data.damage - 1
    THB_Utility.removeStatusMark(player, "@@hezui")
  end,
})

return jiu_Effect
